home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 4 / Amiga Tools 4.iso / tools / mail-tools / thor / thor_2.22 / thor.lha / rexx / BBSRead / JoinConfs.br < prev    next >
Text File  |  1995-12-18  |  4KB  |  123 lines

  1. /*  JoinConfs.br
  2.  *
  3.  *  Arexx script for joining confs. 
  4.  *
  5.  *  Script by: Eivind Nordseth, Ultima Thule Software.
  6.  */
  7.  
  8.     options results
  9. /*    trace results */
  10.  
  11.     parse arg argument
  12.     template = 'BBSNAME/A,OLDCONF/A,NEWCONF/A'
  13.  
  14.     if(argument = '' | argument = '?') then
  15.     do
  16.         say '$VER: JoinConfs.br 3.1 (22.11.94)'
  17.         say 'Template:' template
  18.         say 'This arexx script is ment to be used when a conference changes'
  19.         say 'name, and you have both the old and new conference in your'
  20.         say 'database. It will add all messages in the new name conference'
  21.         say 'to the old name conf. Afterwards is the the old name conference'
  22.         say 'renamed to the name of the new name conference.'
  23.         exit
  24.     end
  25.  
  26.     if ~show('p', 'BBSREAD') then 
  27.     do
  28.         address command
  29.             "run >nil: `GetEnv THOR/THORPath`bin/LoadBBSRead"
  30.             "WaitForPort BBSREAD"
  31.     end
  32.  
  33.     address BBSREAD
  34.  
  35.     /* Bit numbers for message flags */
  36.  
  37.     MDB_READ          =  0   /* Message is read. */
  38.     MDB_REPLIED       =  1   /* Message is replied. */
  39.     MDB_PRIVATE       =  2   /* Message is private. */
  40.     MDB_TO_USER       =  3   /* Message is to the user. */
  41.     MDB_FROM_USER     =  4   /* Message is from the user. */
  42.     MDB_DELETED       =  5   /* Message is deleted. */
  43.     MDB_UNRECOVERABLE =  6   /* Message is can not be undeleted. */
  44.     MDB_KEEP          =  7   /* Keep message. Message will not be deleted during conference packing. */
  45.     MDB_TO_ALL        =  8   /* Message is to all. (has no reciever) */
  46.     MDB_XPK_TEXT      =  9   /* Message text is Xpk'ed. (Private flag) */
  47.     MDB_MARKED        = 10   /* Message is marked.  */
  48.     MDB_URGENT        = 11   /* Message is urgent.    */
  49.     MDB_IMPORTANT     = 12   /* Message is important. */
  50.     MDB_SUPERMARKED   = 13   /* Message will not be unmarked as long as this flag is set. */
  51.  
  52.     rc = 0
  53.     signal on ERROR 
  54.  
  55.     READARGS template ARGS CMDLINE argument
  56.  
  57.     GETCONFDATA ARGS.BBSNAME ARGS.OLDCONF OLDCONFDATA
  58.  
  59.     GETCONFDATA ARGS.BBSNAME ARGS.NEWCONF NEWCONFDATA
  60.  
  61.     do i= NEWCONFDATA.FIRSTMSG to NEWCONFDATA.LASTMSG
  62.  
  63.         drop MSGTAGS.
  64.  
  65.         READBRMESSAGE ARGS.BBSNAME ARGS.NEWCONF i headstem MSGTAGS textstem MSGTAGS datastem MSGDATA
  66.  
  67.         if ~bittst(MSGDATA.FLAGS,MDB_DELETED) then
  68.         do
  69.             exargs = ''
  70.             if ~bittst(MSGDATA.FLAGS,MDB_MARKED)   then exargs = exargs || ' DONTMARKMESSAGE' 
  71.             if bittst(MSGDATA.FLAGS,MDB_PRIVATE)   then exargs = exargs || ' PRIVATE'
  72.             if bittst(MSGDATA.FLAGS,MDB_READ)      then exargs = exargs || ' READ'
  73.             if bittst(MSGDATA.FLAGS,MDB_URGENT)    then exargs = exargs || ' URGENT'
  74.             if bittst(MSGDATA.FLAGS,MDB_IMPORTANT) then exargs = exargs || ' IMPORTANT'
  75.         
  76.             say 'Writing message' i ' in' NEWCONFDATA.NAME 'to' OLDCONFDATA.NAME
  77.  
  78.             WRITEBRMESSAGE ARGS.BBSNAME ARGS.OLDCONF stem MSGTAGS exargs
  79.             
  80.             msgnr = result
  81.  
  82.             exargs = ''
  83.     
  84.             if bittst(MSGDATA.FLAGS,MDB_KEEP)    then exargs = exargs || ' SETKEEP'
  85.             if bittst(MSGDATA.FLAGS,MDB_REPLIED) then exargs = exargs || ' SETREPLIED'
  86.  
  87.             hazelevel = MsgHazeLevel(MSGDATA.FLAGS)
  88.             if hazelevel ~= 0 then exargs = exargs || ' HAZELEVEL ' || hazelevel
  89.  
  90.             if exargs ~= '' then UPDATEBRMESSAGE ARGS.BBSNAME ARGS.OLDCONF msgnr exargs
  91.         end
  92.     end
  93.  
  94.     CONFIGCONF ARGS.BBSNAME ARGS.NEWCONF DELETECONF
  95.  
  96.     CONFIGCONF ARGS.BBSNAME ARGS.OLDCONF NEWNAME NEWCONFDATA.NAME BBSCONFNR OLDCONFDATA.BBSCONFNR
  97.  
  98.     say 'All done!'
  99.  
  100.     exit
  101.  
  102. ERROR:
  103.     if(rc ~= 0) then 
  104.     do
  105.         say 'Error' rc 'in line' SIGL ':' BBSREAD.LASTERROR
  106.         exit
  107.     end
  108.     exit
  109.  
  110.  
  111. MsgHazeLevel: PROCEDURE
  112. ARG msgflags
  113.  
  114.     MDB_HAZE_BIT0     = 24   /* Message haze level bit 0. */
  115.     MDB_HAZE_BIT1     = 25   /* Message haze level bit 1. */
  116.  
  117.     hazelevel = 0
  118.  
  119.     if bittst(msgflags, MDB_HAZE_BIT0) then hazelevel = hazelevel + 1
  120.     if bittst(msgflags, MDB_HAZE_BIT1) then hazelevel = hazelevel + 2
  121.  
  122.     return hazelevel
  123.